package com.tesis_2.Utils;

import com.example.tesis_2.R;
import com.tesis_2.BL.BLLocales;
import com.tesis_2.BL.BLRestaurants;
import com.tesis_2.MO.MOLocal;
import com.tesis_2.MO.MORestaurant;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

public class UTLocalesCategoryAdapter extends BaseAdapter {
	
	private Context context;
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		 
		LayoutInflater inflater = (LayoutInflater) context
			.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
 		View view;
 
		if (convertView == null) {
			
			view = new View(context);
			
			
			
		} else {
			//Toast.makeText(context, "null", 2).show();
			view = (View) convertView;
		}

		view = inflater.inflate(R.layout.activity_locales_category_item, null);
		
		((TextView) view.findViewById(R.id.txvNombre_locales_category_item)).setText(((MOLocal)getItem(position)).getName());
		((TextView) view.findViewById(R.id.txvNombreRest_locales_category_item)).setText(BLRestaurants.getRestById(((MOLocal)getItem(position)).getRest_id()).getName());
		((TextView) view.findViewById(R.id.txvDirecc_locales_category_item)).setText(((MOLocal)getItem(position)).getName());
		((RatingBar) view.findViewById(R.id.rbCalificacion_locales_category_item)).setRating(((MOLocal)getItem(position)).getRate());
		
		return view;
	}
	
	
	public UTLocalesCategoryAdapter(Context context) {
		this.context = context;
		
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return BLLocales.getLsLocal().size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return BLLocales.getLsLocal().get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return BLLocales.getLsLocal().get(position).getId();
	}

	
	
}
